package com.feizhoutuobang.shapeline.bo.impl;

import java.io.File;
import java.io.IOException;
import java.util.Date;

import com.feizhoutuobang.shapeline.bo.Image;
import com.feizhoutuobang.shapeline.util.Calendar;

public class ImageImpl implements Image {

	private String id = "";
	private String src;
	private String path = "";
	private String fetchTime = Calendar.INVALID_TIME;
	
	@Override
	public String getId() {
		return id;
	}

	@Override
	public void setId(String id) {
		this.id = id;
	}

	@Override
	public String getSrc() {
		return src;
	}

	@Override
	public void setSrc(String src) {
		this.src = src;
	}

	@Override
	public File getImage() {
		return new File(path);
	}

	@Override
	public void setImage(File image) {
		try {
			this.path = image.getCanonicalPath();
		} catch (IOException e) {
			//do nothing
		}
	}

	@Override
	public Date getFetchTime() {
		return Calendar.parse(fetchTime);
	}

	@Override
	public void setFetchTime(Date fetchTime) {
		this.fetchTime = Calendar.format(fetchTime);
	}
	
	public String getFetchTime_() {
		return fetchTime;
	}
	
	public void setFetchTime_(String fetchTime) {
		this.fetchTime = fetchTime;
	}
	
	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (obj == null) return false;
		
		Image img = (Image)obj;
		return img.getId().equals(id);
	}
}

